package com.hengxinguotong.zhihuichengjian.widget.pullrefresh;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.widget.NestedScrollView;
import android.util.AttributeSet;

import com.jingchen.pulltorefresh.Pullable;

/**
 * TODO
 *
 * @author hjz
 * @version V1.0.0
 * @since 2019/5/14 15:23
 */

public class PullableNestScrollView extends NestedScrollView implements Pullable
{
    public PullableNestScrollView(@NonNull Context context)
    {
        super(context);
    }

    public PullableNestScrollView(@NonNull Context context, @Nullable AttributeSet attrs)
    {
        super(context, attrs);
    }

    public PullableNestScrollView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr)
    {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean canPullDown()
    {
        if (getScrollY() == 0)
            return true;
        else
            return false;
    }

    @Override
    public boolean canPullUp()
    {
        if (getScrollY() >= (getChildAt(0).getHeight() - getMeasuredHeight()))
            return true;
        else
            return false;
    }
}
